import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TaskEmployeeVO, TaskEmployeeForm, TaskEmployeeQuery } from '@/api/agriculture/taskEmployee/types';

/**
 * 查询批次任务工人列表
 * @param query
 * @returns {*}
 */

export const listTaskEmployee = (query?: TaskEmployeeQuery): AxiosPromise<TaskEmployeeVO[]> => {
  return request({
    url: '/agriculture/taskEmployee/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询批次任务工人详细
 * @param id
 */
export const getTaskEmployee = (id: string | number): AxiosPromise<TaskEmployeeVO> => {
  return request({
    url: '/agriculture/taskEmployee/' + id,
    method: 'get'
  });
};

/**
 * 新增批次任务工人
 * @param data
 */
export const addTaskEmployee = (data: TaskEmployeeForm) => {
  return request({
    url: '/agriculture/taskEmployee',
    method: 'post',
    data: data
  });
};

/**
 * 修改批次任务工人
 * @param data
 */
export const updateTaskEmployee = (data: TaskEmployeeForm) => {
  return request({
    url: '/agriculture/taskEmployee',
    method: 'put',
    data: data
  });
};

/**
 * 删除批次任务工人
 * @param id
 */
export const delTaskEmployee = (id: string | number | Array<string | number>) => {
  return request({
    url: '/agriculture/taskEmployee/' + id,
    method: 'delete'
  });
};

// 根据taskId和employeeId删除批次任务工人
export function delTaskEmployeeByTaskIdAndEmployeeId(taskId, employeeId) {
  return request({
    url: '/agriculture/taskEmployee/' + taskId + '/' + employeeId,
    method: 'delete'
  });
}
